

* Table 7


	* Identify model with best fit
		forvalues v =1(1)5 {
			qui: insheet using "${data}v5_Parameters_`v'.csv"
			qui: destring v7, replace force
			qui: destring v8, replace force

			qui: su v7 if _n ==1
			qui: global lv`v' : di %4.1f `r(mean)'
			qui: su v8 if _n ==1
			qui: global flag`v' = `r(mean)'

			qui: clear
		}
		qui:set obs 5
		qui:ge loss =.
		qui:ge flag =.

		qui:ge sim = _n
		forvalues v =1(1)5 {
			qui: replace loss = ${lv`v'} if sim == `v'
			qui: replace flag = ${flag`v'} if sim == `v'
		}
		gsort loss sim
		su sim if _n ==1
		global best1 =    `r(mean)'


		clear
		
	* Retrieve effort
		insheet using "${data}v5_Moments_all_${best1}.csv"
		
		ge moment = _n
		drop if moment >16 

		ge m= 1 if moment <5
		replace m = 2 if moment >4 & moment <9 
		replace m = 3 if moment >8  &moment <13
		replace m = 4 if moment >12 

		su v1 if _n ==4
		global a1_d = `r(mean)'
		
		su v1 if _n ==8
		global a2_d = `r(mean)'
		
		clear


	* Retrieve standard errors

	insheet using "${data}v5_Bootstrap.csv"
	
	
	forvalues v = 1(1)6{
		su v`v', d
		su v`v' if v`v' < `r(p99)'
		local s`v' : di %4.1f `r(sd)'
	}
	
	count
	local obs = `r(N)'
	count if v1 !=0
	local test1 = `r(N)'
	clear 



	insheet using "${data}v5_Parameters_${best1}.csv"
	

	destring v2, replace force
	su v2 if _n ==3
	local a2_c = `r(mean)'
	su v2 if _n ==4
	local a2_d = `r(mean)'
	keep v1 
	drop if _n >7

	destring v1, replace force
	
	

	forvalues v = 1(1)7{
		su v1 if _n == `v'
		local r`v' : di %4.1f `r(mean)'
	}
	display "r5 " `r5'
	display "r7 " `r7'
	display "r1 " `r1'
	display "r2 " `r2'

	local r8 : di %4.2f (`r2'+ (`r1' * `a2_c')) / (`r2') -1
	local r9 : di %4.2f (`r2'+ (`r1' * `a2_d')) / (`r2') -1
	local r10 : di %4.1f  (`r3') * (${a1_d})^2
	local r11 : di %4.1f  (`r4') * (${a2_d})^2
	local r8  = `r8'*100
	local r9 = `r9'*100
	display `r8'
	display ${a2_c}
	display ${a2_d}

	

	#delimit ;
	file open myfile using "${output}Table7.tex", write replace;
	file write myfile   _n "\begin{tabular}{lc}"			
	_n "\thickhline"
	_n "& \multicolumn{1}{c}{(1)\mbox{\ }}   \\"
	_n "\hline"		
	_n "\mbox{}\\"
	_n " Complementarity \$\gamma\$ & `r1'    \\ "	
	_n "  & (`s1')    \\ "	
	_n " Worker baseline incentive \$b_1\$  & `r5'     \\ "	
	_n "  & (`s5')    \\ "	
	_n " Supervisor baseline incentive  \$b_2\$ 	    &`r6'  \\	"
	_n "  & (`s6')    \\ "	
	_n "  \$\alpha\$ & `r2'    \\ "	
	_n "  & (`s2')    \\ "	
	_n " \mbox{}\\"
	_n " \hline"
	_n " Calibrated friction \$z\$ & 3.6   \\ "	
	_n " \mbox{}\\"
	_n "  \$ \Delta\$ in marginal product of worker effort (shared incentive)	    &`r8' \% \\	"
	_n "  \$ \Delta\$ in marginal product of worker effort 	(control)    &`r9' \% \\	"
	_n "  Total worker cost of effort	(control)    &`r10'  \\	"
	_n "  Total supervisor cost of effort	(control)    &`r11'  \\	"

	_n "\thickhline"
	_n "\end{tabular}" 
		_n " \mbox{}\\" 
	_n "\footnotesize"
	_n " Notes: The first panel of the table shows parameter estimates obtained using minimum distance estimation.  We use eight empirical moments: supervisor effort in each one of the four treatments, and number of visits per month in each one of the four experimental groups. Supervisor effort is proxied by the proportion of households that receive a visit where the worker is accompanied by the supervisor.  Costs are expressed in thousand SLL. Boostrapped standard errors are reported in parenthesis (we bootstrap the estimation 500 times and truncate the estimated coefficients at the 99th percentile of the distribution). The second panel first shows the calibrated value of contractual frictions. Second, it shows some quantities implied by the parameter estimates. To calculate the change in the marginal product of worker effort we take the derivative of the production function with respect to worker effort (i) with $\gamma=`r1'$ and supervisor effort fixed at the level indicated in parenthesis, and (ii) with $\gamma =0$. To calculate the total cost of an agent effort we multiply the unit cost of effort by the average effort exerted by the agent in the control group.";
	file close myfile;
	#delimit cr
	

	
exit

 

